package edu.njfu.networkdemo.kotinlearning

import com.google.gson.Gson
import edu.njfu.networkdemo.model.User
import com.google.gson.reflect.TypeToken as TypeToken1

fun main() {
    val users=ArrayList<User>();
    users.add(User("zhangsan","123"))
    users.add(User("lisi","123"))
    val json = Gson().toJson(users)
    //println(json)
    val user2=Gson().fromJson<List<User>>(json, object:TypeToken1<List<User>>(){}.type)
    for( u in user2){
        println(u.username+","+u.password)
    }
}